#include "bsp_adc.h"
bsp_adc_channel_cfg_t ch[2]
{
    {ADC_SQRCH_0, ADC_IN0, ADC_SAMPLE_CLK30},
    {ADC_SQRCH_1, ADC_IN1, ADC_SAMPLE_CLK30},
}
bsp_adc_init_t adc_cfg = {
    ADC_WORKMODE_ONESHOT,
    ADC_CLKSRC_DIV8,
    ADC_ENS_SQRCH0_1,
    2,
    ch,
};

void BSP_ADC_Init(bsp_adc_init_t *adc_cfg)
{
    // TODO
    ADC_InitTypeDef             ADC_InitStruct;
    ADC_SqrInitTypeDef          ADC_SqrInitStruct;

    MemClr(&ADC_InitStruct, sizeof(ADC_InitStruct));
    MemClr(&ADC_SqrInitStruct, sizeof(ADC_SqrInitStruct));
    // 使能外设时钟
    HAL_SYSCTRL_ADC_CLK_ENABLE();
    // 配置 ADC，单次转换模式
    ADC_InitStruct.WorkMode     = adc_cfg->Mode;               // 单次转换模式
    ADC_InitStruct.ClockSource  = adc_cfg->clkSrc_div;                    // ADCCLK = PCLK/8 = 6MHz
    ADC_InitStruct.BgrEn        = ADC_BGR_ENABLE;
    ADC_InitStruct.TempSensorEn = ADC_TS_DISABLE;
    HAL_ADC_Init(&ADC_InitStruct);
    HAL_ADC_Enable();   //使能ADC

    ADC_SqrInitStruct.SqrEns = adc_cfg->channel_sel;
    for(int i= 0;i<adc_cfg->channel_num;i++)
    {
        switch (i)
        {
            case 0:
                ADC_SqrInitStruct.SqrCh0In = adc_cfg->ch[i].Channel;
                ADC_SqrInitStruct.SqrCh0Sam = adc_cfg->ch[i].Sample_time;
                break;
            case 1:
                ADC_SqrInitStruct.SqrCh1In = adc_cfg->ch[i].Channel;
                break;
            case 2:
                ADC_SqrInitStruct.SqrCh2In = adc_cfg->ch[i].Channel;
                break;
            case 3:
                ADC_SqrInitStruct.SqrCh3In = adc_cfg->ch[i].Channel;
                break;
            case 4:
                ADC_SqrInitStruct.SqrCh4In = adc_cfg->ch[i].Channel;
                break;
            case 5:
                ADC_SqrInitStruct.SqrCh5In = adc_cfg->ch[i].Channel;
                break;
            case 6:
                ADC_SqrInitStruct.SqrCh6In = adc_cfg->ch[i].Channel;
                break;
            case 7:
                ADC_SqrInitStruct.SqrCh7In = adc_cfg->ch[i].Channel;
                break;
            default:
                break;

        }
    }
    ADC_SqrInitStruct.SqrCh0In = adc_cfg->
}

void BSP_ADC_CH_Configration(bsp_adc_channel_cfg_t *ch_cfg)
{

}

